home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1997 / HAM Radio 1997.iso / vcls / date / tcom / comparm.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-04-08  |  2.1 KB  |  78 lines

  1. {$G+,X+}
  2.  
  3. {Conditional defines that may affect this unit}
  4. {$I AWDEFINE.INC}
  5.  
  6. {*********************************************************}
  7. {*                   COMPARM.PAS 1.01                    *}
  8. {*        Copyright (c) TurboPower Software 1995         *}
  9. {*                 All rights reserved.                  *}
  10. {*********************************************************}
  11.  
  12. unit Comparm;
  13.  
  14. interface
  15.  
  16. uses
  17.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  18.   Forms, Dialogs, StdCtrls, ExtCtrls, Buttons, AdMisc, AdPort, TComIni;
  19.  
  20. type
  21.   TComParametersForm = class(TForm)
  22.     PortGroup: TRadioGroup;
  23.     BaudGroup: TRadioGroup;
  24.     ParityGroup: TRadioGroup;
  25.     DataBitsGroup: TRadioGroup;
  26.     StopBitsGroup: TRadioGroup;
  27.     OkBtn: TBitBtn;
  28.     CancelBtn: TBitBtn;
  29.     HelpBtn: TBitBtn;
  30.     procedure OkBtnClick(Sender: TObject);
  31.  
  32.   public
  33.     constructor Create(AOwner : TComponent); override;
  34.   end;
  35.  
  36. implementation
  37.  
  38. {$R *.DFM}
  39.  
  40. constructor TComParametersForm.Create(AOwner : TComponent);
  41. begin
  42.   inherited Create(AOwner);
  43.  
  44.   {set radio buttons to default values}
  45.   case (Baud div 10) of
  46.     30   : BaudGroup.ItemIndex := 0;
  47.     60   : BaudGroup.ItemIndex := 1;
  48.     120  : BaudGroup.ItemIndex := 2;
  49.     240  : BaudGroup.ItemIndex := 3;
  50.     480  : BaudGroup.ItemIndex := 4;
  51.     960  : BaudGroup.ItemIndex := 5;
  52.     1920 : BaudGroup.ItemIndex := 6;
  53.     3840 : BaudGroup.ItemIndex := 7;
  54.     5760 : BaudGroup.ItemIndex := 8;
  55.     11520: BaudGroup.ItemIndex := 9;
  56.   end;
  57.  
  58.   PortGroup.ItemIndex     := Ord(Com[4]) - Ord('1');
  59.   ParityGroup.ItemIndex   := Ord(Parity);
  60.   DataBitsGroup.ItemIndex := 8 - Databits;
  61.   StopBitsGroup.ItemIndex := Stopbits - 1;
  62. end;
  63.  
  64. procedure TComParametersForm.OkBtnClick(Sender: TObject);
  65. const
  66.   Bauds : array[0..9] of LongInt = (300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200);
  67.  
  68. begin
  69.   Baud     := Bauds[BaudGroup.ItemIndex];
  70.   Com[4]   := Char(Ord('1') + PortGroup.ItemIndex);
  71.   Parity   := TParity(ParityGroup.ItemIndex);
  72.   Databits := 8 - DataBitsGroup.ItemIndex;
  73.   Stopbits := StopBitsGroup.ItemIndex + 1;
  74. end;
  75.  
  76. end.
  77.  
  78.